<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./node_modules/axios/dist/axios.js"></script>
</head>

<body>
    <div id="app" >
        <button @click="readingModel">阅读模式</button>
        <button @click="eyeshield">护眼模式</button>
        <div ref="read">
            <ul>
                <li v-for="(item,index) in list" :key="index">
                    <h4 >{{item.title}}</h4>
                    <p >
                        {{item.content}}
                    </p>
                </li>
            </ul>
        </div>


    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                list: [],
            },
            mounted() {
                this.getData();
            },
            methods: {
                getData() {
                    axios.get("https://v2.alapi.cn/api/joke", {
                        params: {
                            token: 'ssWu3bM8uLWuX4Vf'
                        }
                    })
                        .then(
                            res => {
                                this.list = res.data.data;
                            },
                            err =>{
                                console.log("请求失败");
                            }
                        )
                },

                readingModel(){
                    this.$refs.read.style.backgroundColor="rgb(250, 249, 222)";
                    this.$refs.read.style.fontSize="18px";
                },
                eyeshield(){
                    this.$refs.read.style.backgroundColor="rgb(227, 237, 205)";
                    this.$refs.read.style.fontSize="25px";
                }
            }

        })
    </script>

</body>

</html>